#!/usr/bin/env python
# -*- coding:utf-8 -*-

from flask_restful import Resource, reqparse
from flask import jsonify

from controller.testQuestionController import TestQuestionController
from utils import commons
from utils.response_code import RET


class TestQuestionOtherResource(Resource):

    @classmethod
    def sensitive_update(cls, question_id):
        if not question_id:
            return jsonify(code=RET.NODATA, message='primary key missed', error='primary key missed')

        parser = reqparse.RequestParser()
        parser.add_argument('question_type', location='form', required=False, help='question_type参数类型不正确或缺失')
        parser.add_argument('is_delete', location='form', required=False, help='is_delete参数类型不正确或缺失')
        
        kwargs = parser.parse_args()
        kwargs = commons.put_remove_none(**kwargs)
        kwargs['question_id'] = question_id

        res = TestQuestionController.update(**kwargs)

        return jsonify(code=res['code'], message=res['message'], data=res['data'])
